import requests
# 接口文档要素
login_url = 'http://localhost:6088/api/User'
login_headers = {'Content-Type':'application/json'}
login_method = 'post'
login_body = {
    'username' : 'admin',
    'password' : '123'
}
rep = requests.post(login_url,headers = login_headers,json=login_body)
print(rep.status_code)
print(rep.headers)
print(rep.json())
print('----------------------------------')
# 下游代码
# Authorization = rep.headers['Authorization']
Authorization = rep.headers.get('Authorization','没有授权码') # 降低代码风险
print(Authorization)
user_url = 'http://localhost:6088/api/User?IsEnabled=true&Page=1'
url_headers = {'Authorization': Authorization}
user_method = 'get'

rep = requests.get(user_url,headers = url_headers)
print(rep.json())

